package org.javamessage;

import javax.annotation.Resource;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

@Service
public class MessageTemplate {
	
	@Resource
	private RabbitTemplate  directTemplate ;
	
	
	
	

	public RabbitTemplate getRabbitTemplate() {
		return directTemplate;
	}

	public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
		this.directTemplate = rabbitTemplate;
	}



	public  void sendMultipleMessage(Object msg){
		directTemplate.convertAndSend("myFanoutE","fanout",msg);
	}
	
	public  void sendSingleMessage(Object msg){
		directTemplate.convertAndSend("myDirectE","direct",msg);
		
		directTemplate.sendAndReceive((Message)msg);
	}

}
